/*
 * @Description:
 * @Autor: 人生
 * @Date: 2020-09-27 10:40:06
 * @,@LastEditors: ,: 人生
 */
const webpack = require("webpack");
const path = require("path");
function resolve(dir) {
  return path.join(__dirname, dir);
}
module.exports = {
  configureWebpack: {
    plugins: [
      //优化moment打包文件，如果引入了./locale，忽略掉不引入，手动引入需要的语言包
      new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
    ]
  },
  chainWebpack: config => {
    config.resolve.alias.set("@$", resolve("src"));

    const svgRule = config.module.rule("svg");
    svgRule.uses.clear();
    svgRule
      .oneOf("inline")
      .resourceQuery(/inline/)
      .use("vue-svg-icon-loader")
      .loader("vue-svg-icon-loader")
      .end()
      .end()
      .oneOf("external")
      .use("file-loader")
      .loader("file-loader")
      .options({
        name: "assets/[name].[hash:8].[ext]"
      });
  },
  lintOnSave: false,
  devServer: {
    // development server port 8000
    port: 8000,
    // host: "192.168.31.146",
    overlay: {
      warnings: false,
      errors: false
    },
    proxy: {
      "/api": {
        target: "http://zj.test.the6.cc/web",
        ws: false,
        pathRewrite: {
          // pathRewrite表示路径重写，key表示一个正则，value表示别名
          "^/api": "" // 即用 '/api'表示'http://localhost:3000/api'
        },
        changeOrigin: true
      },
      "/oss": {
        target: "https://zj-knowledge-public.oss-cn-beijing.aliyuncs.com/",
        ws: false,
        pathRewrite: {
          // pathRewrite表示路径重写，key表示一个正则，value表示别名
          "^/oss": "" // 即用 '/api'表示'http://localhost:3000/api'
        },
        changeOrigin: true
      }
    }
  }
};
